home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / ALL_IN_ONE2109644152008.psc / SEND CODE / ClassMaster.cls next >
Text File  |  2008-04-15  |  13KB  |  330 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "ClassMaster"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Public Sub additems(ByVal Id_Field As String, ByVal fieldname As String, ByVal tablename As String, cBox As ComboBox)
  15. Dim i As Integer
  16. Dim Rs As Recordset
  17. Set Rs = New Recordset
  18. Rs.Open "select distinct(" & fieldname & ")," & Id_Field & " from " & tablename & "  where del_flag=0 and company_Id=" & Global_CompanyId & " order by " & fieldname & " asc", con, adOpenKeyset, adLockOptimistic
  19. If Rs.RecordCount = 0 Then
  20. Exit Sub
  21. Else
  22.  Rs.MoveFirst
  23.  While Not Rs.EOF
  24.   cBox.List(i) = Rs.Fields(0).Value
  25.   cBox.ItemData(i) = Rs.Fields(1).Value
  26.   i = i + 1
  27.   Rs.MoveNext
  28.  Wend
  29. End If
  30. End Sub
  31. Public Sub AddItemCityStateCountry(ByVal fieldname As String, ByVal tablename As String, cBox As ComboBox)
  32. Dim i As Integer
  33. Dim Rs As Recordset
  34. Set Rs = New Recordset
  35. Rs.Open "select distinct(" & fieldname & ") from " & tablename & "  order by " & fieldname & " asc", con, adOpenKeyset, adLockOptimistic
  36. If Rs.RecordCount = 0 Then
  37. Exit Sub
  38. Else
  39.  Rs.MoveFirst
  40.  While Not Rs.EOF
  41.   cBox.List(i) = Rs.Fields(0).Value
  42.   i = i + 1
  43.   Rs.MoveNext
  44.  Wend
  45. End If
  46. End Sub
  47. Public Function DuplicateCheck(ByVal tablename As String, ByVal SearchField As String, ByVal searchvalue As String) As Boolean
  48. Dim rsopen As Recordset
  49. Set rsopen = New Recordset
  50. rsopen.Open "select * from " & tablename & " where " & SearchField & "= '" & Trim(StringFormat(searchvalue)) & "'  and company_Id=" & Global_CompanyId & "  And del_Flag = false", con, adOpenKeyset, adLockOptimistic
  51. If rsopen.RecordCount = 0 Then
  52.  'MsgBox ("record not found")
  53.   DuplicateCheck = False
  54. Else
  55.  'MsgBox ("record exist")
  56.  DuplicateCheck = True
  57. End If
  58. End Function
  59. Sub proLogOut()
  60. MDIForm1.mnuLibStructure.Enabled = False
  61. MDIForm1.mnuIssueReturn.Enabled = False
  62. MDIForm1.submnuShelfArrangement.Enabled = False 'vikjk
  63. MDIForm1.mnuAsset.Enabled = False
  64. MDIForm1.mnuCatalog.Enabled = False
  65. MDIForm1.mnuAcquisition.Enabled = False
  66. MDIForm1.mnuSearch.Enabled = False
  67. MDIForm1.mnuQueries.Enabled = False
  68. MDIForm1.mnuRepot.Enabled = False
  69. MDIForm1.submnuBackUp.Enabled = False
  70. End Sub
  71. Sub proUserLogin()
  72. MDIForm1.mnuLibStructure.Enabled = False
  73. MDIForm1.mnuIssueReturn.Enabled = True
  74. MDIForm1.submnuShelfArrangement.Enabled = False 'vikjk
  75. MDIForm1.mnuAsset.Enabled = True
  76. MDIForm1.mnuCatalog.Enabled = True
  77.    MDIForm1.submnuOrderEntry.Enabled = False
  78.    MDIForm1.submnuOrderPayment.Enabled = False
  79.    MDIForm1.submnuOrderPlace.Enabled = False
  80.    MDIForm1.submnuReceive.Enabled = True
  81. MDIForm1.mnuAcquisition.Enabled = False
  82. MDIForm1.mnuSearch.Enabled = True
  83. MDIForm1.mnuQueries.Enabled = True
  84. MDIForm1.mnuRepot.Enabled = True
  85. MDIForm1.submnuBackUp.Enabled = False
  86. End Sub
  87. Sub proAdminLogin()
  88. MDIForm1.mnuLibStructure.Enabled = True
  89. MDIForm1.mnuIssueReturn.Enabled = True
  90. MDIForm1.submnuShelfArrangement.Enabled = True 'vikjk
  91. MDIForm1.mnuAsset.Enabled = True
  92. MDIForm1.submnuStationary.Enabled = True
  93. MDIForm1.mnuCatalog.Enabled = True
  94.    MDIForm1.submnuOrderEntry.Enabled = True
  95.    MDIForm1.submnuOrderPayment.Enabled = True
  96.    MDIForm1.submnuOrderPlace.Enabled = True
  97.    MDIForm1.submnuReceive.Enabled = True
  98. MDIForm1.mnuAcquisition.Enabled = False
  99. MDIForm1.mnuSearch.Enabled = True
  100. MDIForm1.mnuQueries.Enabled = True
  101. MDIForm1.mnuRepot.Enabled = True
  102. MDIForm1.submnuGenAssets.Enabled = True
  103. MDIForm1.submnuBackUp.Enabled = True
  104. End Sub
  105. Public Function Country_State_City_Entry(country1 As ComboBox, state1 As ComboBox, city1 As ComboBox) As Integer
  106.  Dim strCountry, strState, strCity As String
  107.  Dim rs1, rsSearch1, rs2, rsSearch2, rs_2, rs3, rsSearch3, rs_31, rs_32 As Recordset
  108.  Set rs1 = New Recordset
  109.  Set rsSearch1 = New Recordset
  110.  Set rs2 = New Recordset
  111.  Set rsSearch2 = New Recordset
  112.  Set rs3 = New Recordset
  113.  Set rsSearch3 = New Recordset
  114.  Set rs_2 = New Recordset
  115.  Set rs_31 = New Recordset
  116.  Set rs_32 = New Recordset
  117.  
  118. ''------------Insertion into Country_master---------------
  119.  rsSearch1.Open "select country from country_master where country='" & StringFormat(country1.Text) & "'", con, adLockOptimistic, adOpenKeyset
  120.  If rsSearch1.RecordCount = 0 Then
  121.     rs1.Open "select Max(country_id) from country_master", con, adLockOptimistic, adOpenKeyset
  122.     Dim countryID As Integer
  123.     countryID = rs1.Fields(0).Value
  124.     If countryID = 0 Then
  125.        countryID = 1
  126.     Else
  127.     countryID = countryID + 1
  128.     End If
  129.     strCountry = "insert into country_master values(" & country_id & ",'" & StringFormat(country1.Text) & "')"
  130.     con.Execute (strCountry)
  131.  End If
  132.  
  133.  
  134. ''---------Insertion Into State_Master--------------------
  135.  rsSearch2.Open "select state from state_master where state='" & StringFormat(state1.Text) & "' and country_id in (select country_id from country_master where country='" & Trim(country1.Text) & "')", con, adLockOptimistic, adOpenKeyset
  136.  If rsSearch2.RecordCount = 0 Then
  137.     rs2.Open "select Max(state_id) from state_master", con, adLockOptimistic, adOpenKeyset
  138.     Dim stateID As Integer
  139.     stateID = rs2.Fields(0).Value
  140.     If stateID = 0 Then
  141.        stateID = 1
  142.     Else
  143.        stateID = stateID + 1
  144.     End If
  145.     rs_2.Open "select country_id from country_master where country='" & StringFormat(country1) & "'", con, adLockOptimistic, adOpenKeyset
  146.     Dim con_id As Integer
  147.     con_id = rs_2.Fields(0).Value
  148.     strState = "insert into state_master values(" & stateID & "," & con_id & ",'" & StringFormat(state1.Text) & "')"
  149.     con.Execute (strState)
  150.  End If
  151.  
  152.  
  153. ''--------------Insertion into City_master----------------
  154. rsSearch3.Open "select city from city_master where city='" & StringFormat(city1.Text) & "' and state_id in(select state_id from state_master where state='" & StringFormat(state1.Text) & "' and country_id in(select country_id from country_master where country='" & StringFormat(country1.Text) & "'))", con, adLockOptimistic, adOpenKeyset
  155. If rsSearch3.RecordCount = 0 Then
  156.     Dim stateID2, cityID As Integer
  157.     rs3.Open "select state_id from state_master where state='" & StringFormat(state1.Text) & "' and country_id in(select country_id from country_master where country='" & StringFormat(country1.Text) & "')", con, adLockOptimistic, adOpenKeyset
  158.     stateID2 = rs3.Fields(0).Value
  159.     rs_31.Open "select Max(city_id) from city_master ", con, adLockOptimistic, adOpenKeyset
  160.     cityID = rs_31.Fields(0).Value
  161.     If cityID = 0 Then
  162.        cityID = 1
  163.     Else
  164.        cityID = cityID + 1
  165.     End If
  166.     strCity = "insert into city_master values(" & cityID & "," & stateID2 & ",'" & StringFormat(city1.Text) & "')"
  167.     con.Execute (strCity)
  168.  End If
  169.  
  170.  '----------------selection of city id'------------------------------------------------------------
  171. Dim rsSearchcityID As Recordset
  172. Set rsSearchcityID = New Recordset
  173.  rsSearchcityID.Open "select city_id from city_master where city='" & StringFormat(city1.Text) & "' and state_id in(select state_id from state_master where state='" & StringFormat(state1.Text) & "' and country_id in(select country_id from country_master where country='" & StringFormat(country1.Text) & "'))", con, adLockOptimistic, adOpenKeyset
  174.  cityID = rsSearchcityID.Fields(0).Value
  175.  
  176.  Country_State_City_Entry = city_Id 'return city_Id
  177. End Function
  178.  
  179. '---for setting of country state and city in a single click of CityCombo-------------
  180. Public Sub select_City(City_C As ComboBox, State_C As ComboBox, Country_C As ComboBox)
  181. Dim i As Integer
  182. Dim rsState, rsCountry As Recordset
  183.  Set rsState = New Recordset
  184.  rsState.Open "select state from state_master where state_id in (select state_id from city_master where city='" & StringFormat(City_C.Text) & "')", con, adLockOptimistic, adOpenKeyset
  185.  If rsState.RecordCount = 0 Then
  186.  Else
  187.    State_C.Clear
  188.  If rsState.RecordCount > 1 Then
  189.     While Not rsState.EOF
  190.      State_C.List(i) = rsState.Fields(0).Value
  191.      If i = 0 Then 'for selecting first record
  192.         Value = rsState.Fields(0).Value
  193.      End If
  194.        i = i + 1
  195.       rsState.MoveNext
  196.      Wend
  197.      State_C.Text = Value
  198.  Else
  199.     State_C.Text = rsState.Fields(0).Value
  200.  
  201.  End If
  202.  End If
  203.  '-------------------select country-----------------------------------------------------
  204.  Set rsCountry = New Recordset
  205.  rsCountry.Open "select country from country_master where country_id in (select country_id from state_master where state='" & StringFormat(State_C.Text) & "')", con, adLockOptimistic, adOpenKeyset
  206.  If rsCountry.RecordCount = 0 Then
  207.  Else
  208.     Country_C.Clear
  209.    If rsCountry.RecordCount > 1 Then
  210.       While Not rsCountry.EOF
  211.       Combostate.List(i) = rsCountry.Fields(0).Value
  212.       If i = 0 Then 'for selecting first record
  213.       Value = rsCountry.Fields(0).Value
  214.       End If
  215.        i = i + 1
  216.        rsCountry.MoveNext
  217.       Wend
  218.       Country_C.Text = Value
  219.    Else
  220.       Country_C.Text = rsCountry.Fields(0).Value
  221.   End If
  222.  End If
  223. End Sub
  224.  
  225. Public Function ID_Generator(ByVal Table As String, ByVal fieldname As String, ByVal prefix As String) As String
  226.   Dim rs1 As Recordset
  227.   Set rs1 = New Recordset
  228.   rs1.Open "SElect * from " & Table & " where company_Id=" & Global_CompanyId & "", con, adOpenKeyset, adLockOptimistic
  229.   If rs1.RecordCount <= 0 Then
  230.        ID_Generator = 1
  231.        Exit Function
  232.   End If
  233.   Dim Rs As Recordset
  234.   Set Rs = New Recordset
  235.   Rs.Open "select max(" & fieldname & ") from " & Table & " ", con, adLockOptimistic, adOpenKeyset
  236.   Dim ID As String
  237.   If Rs.RecordCount = 0 And prefix = "" Then
  238.      ID = 1
  239.      ID_Generator = Trim(ID)
  240.      Exit Function
  241.   End If
  242.    If Not Rs.RecordCount = 0 And prefix = "" Then
  243.      ID_Generator = Trim(str(Rs.Fields(0).Value + 1))
  244.      Exit Function
  245.   End If
  246.   If Rs.RecordCount = 0 And Not prefix = "" Then
  247.      ID = 1
  248.      ID_Generator = Trim(Trim(prefix) + ID)
  249.      Exit Function
  250.   End If
  251.   If Not Rs.RecordCount = 0 And Not Trim(prefix) = "" Then
  252.      ID_Generator = Trim(Trim(prefix) + str(Rs.Fields(0).Value + 1))
  253.      Exit Function
  254.   End If
  255.   Rs.Close
  256.  End Function
  257. Public Function Date_Check(dt As Date) As Date
  258.   Dim c_Date As Date
  259.   c_Date = Date
  260.   If dt > c_Date Then
  261.    MsgBox "Entry Date should not be More than Current Date", vbInformation + vbOKOnly, "EasyLib"
  262.    dt = Date
  263.   End If
  264.     Date_Check = dt
  265. End Function
  266. Public Sub SetCompany_YEAR(Comp_name As String, financial_Year As String)
  267. Dim Rs As Recordset
  268. Set Rs = New Recordset
  269. Rs.Open "select company_id from company_master where company_name='" & Trim(Comp_name) & "' and del_flag=0", con, adOpenKeyset, adLockOptimistic
  270. If Rs.RecordCount = 0 Then
  271.  MsgBox "Company Does Not Exist", vbInformation + vbOKOnly
  272.  Else
  273. Global_CompanyId = Rs.Fields(0).Value
  274. Global_financialYear = financial_Year
  275. End If
  276. End Sub
  277. '-------------- For searching Id of that perticular rearch value--------
  278. Public Function select_ID(ByVal Id_Field As String, ByVal tablename As String, ByVal SearchField As String, ByVal searchvalue As String) As Integer
  279.    Dim Rs As Recordset
  280.    Set Rs = New Recordset
  281.    Rs.Open "select " & Id_Field & " from " & tablename & " where " & SearchField & " ='" & searchvalue & "'", con, adOpenKeyset, adLockOptimistic
  282.    If Rs.RecordCount = 0 Then
  283.      select_ID = 0
  284.      
  285.    Else
  286.    select_ID = Rs.Fields(0).Value
  287.    End If
  288. End Function
  289. Public Function funSelectMonth(ByVal dd As Date) As String
  290.  Dim i As Integer
  291.  i = Month(dd)
  292.  If i = 1 Then
  293.     funSelectMonth = "Jan"
  294.     Exit Function
  295.  ElseIf i = 2 Then
  296.     funSelectMonth = "Feb"
  297.     Exit Function
  298.  ElseIf i = 3 Then
  299.     funSelectMonth = "Mar"
  300.     Exit Function
  301.  ElseIf i = 4 Then
  302.     funSelectMonth = "Apr"
  303.     Exit Function
  304. ElseIf i = 5 Then
  305.     funSelectMonth = "May"
  306.     Exit Function
  307. ElseIf i = 6 Then
  308.     funSelectMonth = "Jun"
  309.     Exit Function
  310. ElseIf i = 7 Then
  311.     funSelectMonth = "Jul"
  312.     Exit Function
  313. ElseIf i = 8 Then
  314.     funSelectMonth = "Aug"
  315.     Exit Function
  316. ElseIf i = 9 Then
  317.     funSelectMonth = "Sep"
  318.     Exit Function
  319. ElseIf i = 10 Then
  320.     funSelectMonth = "Oct"
  321.     Exit Function
  322. ElseIf i = 11 Then
  323.     funSelectMonth = "Nov"
  324.     Exit Function
  325. Else
  326.     funSelectMonth = "Dec"
  327.     Exit Function
  328. End If
  329. End Function
  330.